

**********
* TABLE 1*
**********

*Election Data
clear
use	"$base\Elections.dta"

estpost sum  turnout invalid right left nparties sh_winner margin if parl==1
est store parl

estpost sum  turnout invalid right left nparties sh_winner margin if st==1
est store st

estpost sum  turnout invalid if pres==1   
est store pres

esttab parl using "Stats_Parl_Elections.tex", replace refcat(turnout "\bfseries{Panel A: Parliamentary Elections}") cells("count(fmt(%9.0g)) mean(fmt(2)) sd(fmt(2)) min(fmt(2)) max(fmt(2))") noobs collabels("Observations" "Mean" "Std. Dev" "Min." "Max.")  label nonum
esttab st using "Stats_St_Elections.tex", replace refcat(turnout "\bfseries{Panel B: State Elections}") cells("count(fmt(%9.0g)) mean(fmt(2)) sd(fmt(2)) min(fmt(2)) max(fmt(2))") noobs collabels("Observations" "Mean" "Std. Dev" "Min." "Max.")  label nonum
esttab pres using "Stats_President_Elections.tex", replace refcat(turnout"\bfseries{Panel C: Presidential Elections}") cells("count(fmt(%9.0g)) mean(fmt(2)) sd(fmt(2)) min(fmt(2)) max(fmt(2))") noobs collabels("Observations" "Mean" "Std. Dev" "Min." "Max.")  label nonum

*Yearly State Data
clear
use	"$base\Expenditures.dta"

replace unemployed_perc=unemployed_perc/100

estpost sum   unemployed_perc pop_thousands admin_exp gen_exp   finance_exp  welfare_exp  educ_exp social_exp  health_exp arts_exp  infras_exp  transport_exp  security_exp  economy_exp  services_exp 
est store expenditures

label variable gen_exp "Representatives and gen. admin"
label variable  finance_exp "Finance"
label variable  educ_exp "Education, sports and science"
label variable social_exp "Social welfare and housing"
label variable health_exp "Health"
label variable arts_exp "Arts, culture and religion"
label variable  transport_exp "Roads and transport"
label variable  security_exp "Public order and security"
label variable economy_exp "Promotion of the economy"
label variable services_exp "Services"
label variable  pop_thousands "Population (in thousands)"
label variable unemployed_perc "Unemployment Rate (\%)"

  
esttab expenditures using "Stats.tex", replace refcat(unemployed_perc "\bfseries{Panel D: Yearly State Data (1980-2012)}"  admin_exp "\bfseries{Administrative Expenditures}" educ_exp "\bfseries{Welfare Expenditures}" transport_exp "\bfseries{Infrastructure Expenditures}"  ) cells("count(fmt(%9.0g)) mean(fmt(2)) sd(fmt(2)) min(fmt(2)) max(fmt(2))") noobs collabels("Observations" "Mean" "Std. Dev" "Min." "Max.")  label nonum



******************************************
** TABLES 3, 5, A.3, A.9, A.11 AND A.12 **
******************************************
clear
use		"$base\Elections.dta"

global trends_parl  trend_parl_*
global trends_st  trend_st_*
global trends_pres  trend_pres_*
global controls_fe i.state_code i.year  l_pop unemployed_perc 


** Table 3
foreach y in turnout invalid {

*Pooled regression
reg `y'  CV_parl CV_st CV_pres parl pres  ${controls_fe}  ${trends_parl} ${trends_st} ${trends_pres}, cluster(state_code) 
		eststo `y'_pooled
		sum `y' if CV==0  
		estadd scalar mean_dep=r(mean)

*Separate by election type
foreach x in parl st pres{
xi: reg `y' CV   ${controls_fe} ${trends_`x'} if `x'==1, cluster(state_code)
		eststo `y'_`x'
		sum `y' if  CV==0    & `x'==1
		estadd scalar mean_dep=r(mean)
}		
}	



*Wild bootstrap p-values: cgmwildboot and cgmreg codes obtained from Judson Caskey's website.  We impose the null hypothesis as suggested in Cameron, Gelbach and Miller (2008)
foreach y in turnout invalid {
cgmwildboot `y' CV_parl CV_st CV_pres parl pres  _Iyear_*  _Istate_cod_*  l_pop unemployed_perc trend_parl_* trend_pres_* trend_st_*, cluster(state_code) bootcluster(state_code) null(0 0 0 . . . . .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   )  reps(999) seed(365476247)  
foreach x in parl st pres{
cgmwildboot `y'  CV  _Iyear_*  _Istate_cod_* l_pop unemployed_perc trend_`x'_* if `x'==1, cluster(state_code) bootcluster(state_code) null(0 . . . . .    . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .    )  reps(999) seed(365476247)
}
}

*Panel A
esttab 	turnout_parl turnout_st turnout_pres turnout_pooled  using "Table3_PanelA.tex", replace  mtitles("Parliamentary"  "State" "Presidential" "Pooled" ) keep(CV CV_parl CV_st CV_pres) order(CV CV_parl CV_st CV_pres) width(1\hsize)  b(3) se(3) star nonotes  nonumbers  starlevels(* 0.10 ** 0.05 *** .01) noobs scalars("N Observations" "r2 R Squared" "mean_dep Mean Turnout (if CV=0)") sfmt (%12.0fc %12.3fc %12.3fc)	
*Panel B
esttab 	invalid_parl invalid_st invalid_pres invalid_pooled  using "Table3_PanelB.tex", replace  mtitles("Parliamentary"  "State" "Presidential" "Pooled" ) keep(CV CV_parl CV_st CV_pres) order(CV CV_parl CV_st CV_pres) width(1\hsize)  b(3) se(3) star nonotes  nonumbers  starlevels(* 0.10 ** 0.05 *** .01) noobs scalars("N Observations" "r2 R Squared" "mean_dep Mean Turnout (if CV=0)") sfmt (%12.0fc %12.3fc %12.3fc)	




** Table 5
foreach x in parl st{
	foreach y in right left minor nparties sh_winner margin {

reg `y' CV ${controls_fe} ${trends_`x'} if `x'==1, cluster(state_code)
		eststo `y'_`x'_rf
		estadd ysumm, mean
	}
	}


*Wild bootstrap p-values
foreach y in left right minor nparties sh_winner margin {
foreach x in parl st{
cgmwildboot `y'  CV  _Iyear_*  _Istate_cod_* l_pop unemployed_perc  trend_`x'_* if `x'==1, cluster(state_code) bootcluster(state_code) null(0 . . . . .    . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .    )  reps(999) seed(365476247)
}
}


*Test equality across election types 
foreach x in  l_pop  unemployed_perc year state_code{
gen `x'_parl=`x' if parl==1
replace `x'_parl=0 if parl==0
gen `x'_st=`x' if st==1
replace `x'_st=0 if st==0
}

foreach y in left right minor nparties sh_winner margin {
reg `y' CV_parl CV_st i.year_parl i.year_st i.state_code_parl i.state_code_st l_pop_parl l_pop_st unemployed_perc_parl unemployed_perc_st  ${trends_parl} ${trends_st}   if st==1 | parl==1, cluster(state_code) noconstant
test CV_parl=CV_st
}	

*Panel A
esttab 	 left_parl_rf right_parl_rf minor_parl_rf nparties_parl_rf sh_winner_parl_rf margin_parl_rf  using "Table5_PanelA.tex", replace  mtitles("Left (\%)" "Right (\%)" "Minor Parties(\%)"   "Num. of Parties" "Share Winner (\%)" "Margin of Victory")  keep(CV) b(3) se(3) star nonotes  nonumbers width(\hsize) starlevels(* 0.10 ** 0.05 *** .01) refcat(CV"\bfseries{Panel A: Parliamentary Elections}") noobs scalars("N Observations" "r2 R Squared" "ymean Mean Dep. Variable") sfmt (%12.0fc %12.3fc %12.3fc)
*Panel B
esttab 	 left_st_rf right_st_rf minor_st_rf nparties_st_rf sh_winner_st_rf margin_st_rf using "Table5_PanelB.tex" , replace  mtitles("Left (\%)" "Right (\%)" "Minor Parties(\%)" "Num. of Parties" "Share Winner (\%)" "Margin of Victory") keep(CV) b(3) se(3) star nonotes  nonumbers width(\hsize) starlevels(* 0.10 ** 0.05 *** .01) refcat(CV "\bfseries{Panel B: State Elections}") noobs scalars("N Observations" "r2 R Squared" "ymean Mean Dep. Variable") sfmt (%12.0fc %12.3fc %12.3fc)



	
** Table A.3
foreach y in turnout invalid {
*Pooled regression
reg `y' CV_parl CV_st CV_pres parl pres  ${controls_fe} ${trends_parl} ${trends_st} ${trends_pres} if year>1978, cluster(state_code) 
		eststo `y'_pooled_sh
		sum `y' if CV==0  & year>1978  
		estadd scalar mean_dep=r(mean)

*Separate by election type
foreach x in parl st pres{
xi: reg `y' CV  ${controls_fe} ${trends_`x'} if `x'==1 & year>1978, cluster(state_code)
		eststo `y'_`x'_sh
		sum `y' if CV==0  & `x'==1 & year>1978 
		estadd scalar mean_dep=r(mean)
}		
}		

*Wild bootstrap p-values
foreach y in turnout invalid {
cgmwildboot `y' CV_parl CV_st CV_pres parl pres  _Iyear_1979- _Iyear_2010  _Istate_cod_*  l_pop unemployed_perc trend_parl_* trend_pres_* trend_st_* if  year>1978, cluster(state_code) bootcluster(state_code) null(0 0 0 .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247)  
foreach x in parl st pres{
cgmwildboot `y'  CV _Iyear_1979-_Iyear_2010  _Istate_cod_*  l_pop unemployed_perc trend_`x'_* if `x'==1  & year>1978, cluster(state_code) bootcluster(state_code) null(0  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  )  reps(999) seed(365476247)
}
}

*Panel A
esttab 	turnout_parl_sh turnout_st_sh turnout_pres_sh turnout_pooled_sh  using "TableA3_PanelA.tex", replace  mtitles("Parliamentary"  "State" "Presidential" "Pooled" ) keep(CV CV_parl CV_st CV_pres) order(CV CV_parl CV_st CV_pres) width(1\hsize)  b(3) se(3) star nonotes  nonumbers  starlevels(* 0.10 ** 0.05 *** .01) noobs scalars("N Observations" "r2 R Squared" "mean_dep Mean Turnout (if CV=0)") sfmt (%12.0fc %12.3fc %12.3fc)	
*Panel B
esttab 	invalid_parl_sh invalid_st_sh invalid_pres_sh invalid_pooled_sh  using "TableA3_PanelB.tex", replace  mtitles("Parliamentary"  "State" "Presidential" "Pooled" ) keep(CV CV_parl CV_st CV_pres) order(CV CV_parl CV_st CV_pres) width(1\hsize)  b(3) se(3) star nonotes  nonumbers  starlevels(* 0.10 ** 0.05 *** .01) noobs scalars("N Observations" "r2 R Squared" "mean_dep Mean Turnout (if CV=0)") sfmt (%12.0fc %12.3fc %12.3fc)	



** Table A.9
	
foreach y in turnout invalid {
reg `y'  CV_parl_lead CV_parl CV_parl_lag CV_st_lead CV_st CV_st_lag CV_pres_lead CV_pres CV_pres_lag  parl st  ${controls_fe} ${trends_parl} ${trends_st} ${trends_pres}, cluster(state_code)
		eststo rob_`y'_pooled
		sum `y' if CV==0  
		estadd scalar mean_dep=r(mean)

	}
	
*Wild bootstrap p-values
foreach y in turnout invalid {
cgmwildboot `y' CV_parl_lead CV_parl CV_parl_lag CV_st_lead CV_st CV_st_lag CV_pres_lead CV_pres CV_pres_lag  parl st   _Iyear_*  _Istate_cod_*  l_pop unemployed_perc trend_parl_* trend_pres_* trend_st_*, cluster(state_code) bootcluster(state_code) null(0 0 0 0 0 0 0 0 0 . . . . .  . . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . .  )  reps(999) seed(365476247)  
}


esttab 	rob_turnout_pooled rob_invalid_pooled using "TableA9.tex", replace  mtitles("Turnout (\%)" "Invalid Votes (\%)") keep(CV_parl_lead CV_parl CV_parl_lag CV_st_lead CV_st CV_st_lag CV_pres_lead CV_pres CV_pres_lag ) order(CV_parl_lead CV_parl CV_parl_lag CV_st_lead CV_st CV_st_lag CV_pres_lead CV_pres CV_pres_lag ) width(1\hsize)  b(3) se(3) star nonotes  nonumbers l starlevels(* 0.10 ** 0.05 *** .01) noobs scalars("N Observations" "r2 R Squared") sfmt (%12.0fc %12.3fc %12.3fc ) 


** Table A.11

foreach x in parl st{
	foreach y in right left minor nparties sh_winner margin {

reg `y' CV ${controls_fe} ${trends_`x'} if `x'==1 & year>1978, cluster(state_code)
		eststo `y'_`x'_rf_sh
		estadd ysumm, mean
	}
	}

	
*Wild bootstrap p-values
foreach y in left right minor nparties sh_winner margin {
foreach x in parl st{
cgmwildboot `y' CV  _Iyear_1979-_Iyear_2010  _Istate_cod_* l_pop unemployed_perc  trend_`x'_* if `x'==1  & year>1978, cluster(state_code) bootcluster(state_code) null(0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247)
}
}
	
*Panel A
esttab 	 left_parl_rf_sh right_parl_rf_sh minor_parl_rf_sh  nparties_parl_rf_sh sh_winner_parl_rf_sh margin_parl_rf_sh  using "TableA11_PanelA.tex", replace  mtitles("Left (\%)" "Right (\%)" "Minor Parties (\%)" "Num. of Parties" "Share Winner (\%)" "Margin of Victory")  keep(CV) b(3) se(3) star nonotes  nonumbers width(\hsize) starlevels(* 0.10 ** 0.05 *** .01) refcat(CV"\bfseries{Panel A: Parliamentary Elections}") noobs scalars("N Observations" "r2 R Squared" "ymean Mean Dep. Variable") sfmt (%12.0fc %12.3fc %12.3fc)
*Panel B
esttab 	 left_st_rf_sh right_st_rf_sh minor_st_rf_sh nparties_st_rf_sh sh_winner_st_rf_sh margin_st_rf_sh using "$TableA11_PanelB.tex" , replace  mtitles("Left (\%)" "Right (\%)" "Minor Parties (\%)"  "Num. of Parties" "Share Winner (\%)" "Margin of Victory") keep(CV) b(3) se(3) star nonotes  nonumbers width(\hsize) starlevels(* 0.10 ** 0.05 *** .01) refcat(CV "\bfseries{Panel B: State Elections}") noobs scalars("N Observations" "r2 R Squared" "ymean Mean Dep. Variable") sfmt (%12.0fc %12.3fc %12.3fc)


** Table A.12
foreach x in parl st{
	foreach y in right left minor nparties sh_winner margin {

	ivregress 2sls `y' (turnout=CV) ${controls_fe} ${trends_`x'} if `x'==1, cluster(state_code)
		eststo `y'_`x'_iv
		estadd ysumm, mean
		estat firststage
	}
	}

*Wild bootstrap p-values
foreach x in parl st{
regress turnout CV  ${controls_fe} ${trends_`x'} if `x'==1, cluster(state_code) 
predict pred_turnout_`x'

foreach y in left right minor nparties sh_winner margin {
cgmwildboot `y' pred_turnout_`x' _Iyear_*  _Istate_cod_* l_pop unemployed_perc  trend_`x'_* if `x'==1, cluster(state_code) bootcluster(state_code) null(0 . . . . .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247)

}
}	

*Panel A
esttab 	 left_parl_iv right_parl_iv minor_parl_iv  nparties_parl_iv sh_winner_parl_iv margin_parl_iv  using "TableA12_PanelA.tex", replace  mtitles("Left (\%)" "Right (\%)" "Minor Parties (\%)" "Num. of Parties" "Share Winner (\%)" "Margin of Victory")  keep(turnout) b(3) se(3) star nonotes  nonumbers width(\hsize) starlevels(* 0.10 ** 0.05 *** .01) refcat(turnout "\bfseries{Panel A: Parliamentary Elections}") noobs scalars("N Observations" "r2 R Squared" "ymean Mean Dep. Variable") sfmt (%12.0fc %12.3fc %12.3fc)
*Panel B
esttab 	 left_st_iv right_st_iv minor_st_iv nparties_st_iv sh_winner_st_iv margin_st_iv using "TableA12_PanelB.tex" , replace  mtitles("Left (\%)" "Right (\%)" "Minor Parties (\%)" "Num. of Parties" "Share Winner (\%)" "Margin of Victory") keep(turnout) b(3) se(3) star nonotes  nonumbers width(\hsize) starlevels(* 0.10 ** 0.05 *** .01) refcat(turnout "\bfseries{Panel B: State Elections}") noobs scalars("N Observations" "r2 R Squared" "ymean Mean Dep. Variable") sfmt (%12.0fc %12.3fc %12.3fc)

** Robustness Checks (Electoral Outcomes in Appendix C)
*Adding Electoral Party of Independents to the main right-wing parties
gen right_2=right+ wdu_perc
gen minor_2=minor-wdu_perc
*Not counting kpo as part of the main left-wing parties
gen minor_3=minor+kpoe_perc
*Sum of the vote shares for the two main parties
gen main=spoe_perc+oevp_perc


foreach y in spoe fpoe oevp kpoe right_2 minor_2 minor_3 main{
foreach x in parl st{
reg `y' CV ${controls_fe} ${trends_`x'} if `x'==1, cluster(state_code)
}
}

*Wild bootstrap p-values
foreach y in spoe fpoe oevp kpoe right_2 minor_2 minor_3 main{
foreach x in parl st{
cgmwildboot `y'  CV  _Iyear_*  _Istate_cod_* l_pop unemployed_perc  trend_`x'_* if `x'==1, cluster(state_code) bootcluster(state_code) null(0 . . . . .    . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .    )  reps(999) seed(365476247)
}
}

	
*****************************************
* TABLES 4, A.4, A.5, A.6, A.7 AND A.10 *
*****************************************

clear
use		"$base\Expenditures.dta"

global controls_fe_trends i.state_code i.year  l_pop unemployed_perc trend_*


** Tables 4 and A.4
foreach x in parl st pres {

		xi: reg l_total_exp CV_`x' ${controls_fe_trends} , cluster(state_code)
		eststo l_total_exp_`x'_rf
		estadd ysumm, mean

		reg l_total_exp_pc CV_`x' ${controls_fe_trends}, cluster(state_code)
		eststo l_total_exp_pc_`x'_rf
		estadd ysumm, mean
		
	foreach y in  admin welfare infras {

	reg l_`y'_exp  CV_`x' ${controls_fe_trends}, cluster(state_code) 
	eststo l_`y'_exp_`x'_rf
		estadd ysumm, mean

	reg l_`y'_exp_pc  CV_`x' ${controls_fe_trends} , cluster(state_code) 
	eststo l_`y'_exp_pc_`x'_rf
		estadd ysumm, mean

	reg `y'_exp_perc  CV_`x' ${controls_fe_trends}, cluster(state_code) 
	eststo `y'_exp_perc_`x'_rf
		estadd ysumm, mean
		
	}
	}
	

	
*Wild bootstrap p-values
foreach x in parl st pres {

cgmwildboot l_total_exp CV_`x'  _Iyear_*   _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 
cgmwildboot l_total_exp_pc CV_`x'  _Iyear_*   _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 

foreach y in  admin welfare infras {

cgmwildboot l_`y'_exp  CV_`x'  _Iyear_*   _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 
cgmwildboot l_`y'_exp_pc  CV_`x'  _Iyear_*  _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 
cgmwildboot `y'_exp_perc CV_`x'  _Iyear_*   _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 

}
}	


	
	
*Test equality across election types
keep  year state_code  turnout_parl turnout_st l_total_exp- l_infras_exp_pc  unemployed_perc  l_pop  CV_parl CV_st  trend_1- trend_9

expand 2
bysort year state_code: gen first=(_n==1)

foreach x in  l_pop  unemployed_perc  trend_1 trend_2 trend_3 trend_4 trend_5 trend_6 trend_7 trend_8 trend_9 year state_code{
gen `x'_parl=`x' if first==1
replace `x'_parl=0 if first==0
gen `x'_st=`x' if first==0
replace `x'_st=0 if first==1
}

replace CV_parl=0 if first==0
replace CV_st=0 if first==1

foreach y in  l_total_exp l_admin_exp l_welfare_exp l_infras_exp  l_total_exp_pc  l_admin_exp_pc l_welfare_exp_pc l_infras_exp_pc  admin_exp_perc welfare_exp_perc infras_exp_perc {
qui reg `y' CV_parl CV_st  l_pop_parl- trend_9_st i.year_parl i.year_st i.state_code_parl i.state_code_st , cluster(state_code)
test CV_parl=CV_st		
	
}

** Table 4
*Panel A
esttab 	 l_total_exp_parl_rf l_admin_exp_parl_rf l_welfare_exp_parl_rf l_infras_exp_parl_rf l_total_exp_pc_parl_rf l_admin_exp_pc_parl_rf l_welfare_exp_pc_parl_rf l_infras_exp_pc_parl_rf admin_exp_perc_parl_rf welfare_exp_perc_parl_rf infras_exp_perc_parl_rf  using "Table4_PanelA.tex", replace mgroups("\underline {Log-Levels}" "\underline {Log-Per Capita}" "\underline {\% of Total}", pattern(1 0 0 0 1 0 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "Total"  "Admin."  "Welfare"  "Infrast."  "Total" "Admin."  "Welfare" "Infrast."  "Admin." "Welfare" "Infrast.") keep(CV_parl) b(3) se(3)  star nonotes  nonumbers staraux l starlevels(* 0.10 ** 0.05 *** .01) refcat(CV_parl "\bfseries{Panel A: Parliamentary Elections}") noobs scalars( "N Observations" "r2 R Squared" "ymean Mean Dep. Variable") sfmt ( %12.0fc %12.3fc %12.3fc )  
*Panel B
esttab 	 l_total_exp_st_rf l_admin_exp_st_rf l_welfare_exp_st_rf l_infras_exp_st_rf l_total_exp_pc_st_rf l_admin_exp_pc_st_rf l_welfare_exp_pc_st_rf l_infras_exp_pc_st_rf admin_exp_perc_st_rf welfare_exp_perc_st_rf infras_exp_perc_st_rf  using "Table4_PanelB.tex", replace mgroups("\underline {Log-Levels}" "\underline {Log-Per Capita}" "\underline {\% of Total}", pattern(1 0 0 0 1 0 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "Total"  "Admin."  "Welfare"  "Infrast."  "Total" "Admin."  "Welfare" "Infrast."  "Admin." "Welfare" "Infrast.") keep(CV_st) b(3) se(3)  star nonotes  nonumbers l starlevels(* 0.10 ** 0.05 *** .01) refcat(CV_st "\bfseries{Panel B: State Elections}") noobs scalars("N Observations" "r2 R Squared" "ymean Mean Dep. Variable" ) sfmt ( %12.0fc %12.3fc %12.3fc  )  

		
** Table A.4
esttab 	 l_total_exp_pres_rf l_admin_exp_pres_rf l_welfare_exp_pres_rf l_infras_exp_pres_rf l_total_exp_pc_pres_rf l_admin_exp_pc_pres_rf l_welfare_exp_pc_pres_rf l_infras_exp_pc_pres_rf admin_exp_perc_pres_rf welfare_exp_perc_pres_rf infras_exp_perc_pres_rf  using "TableA4.tex", replace mgroups("\underline {Log-Levels}" "\underline {Log-Per Capita}" "\underline {\% of Total}", pattern(1 0 0 0 1 0 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "Total"  "Admin."  "Welfare"  "Infrast."  "Total" "Admin."  "Welfare" "Infrast."  "Admin." "Welfare" "Infrast.") keep(CV_pres) b(3) se(3)  star nonotes  nonumbers staraux l starlevels(* 0.10 ** 0.05 *** .01) refcat(CV_pres "\bfseries{Panel C: Presidential Elections}") noobs scalars("N Observations" "r2 R Squared" "ymean Mean Dep. Variable") sfmt (%12.0fc %12.3fc %12.3fc)  



clear
use		"$base\Expenditures.dta"
	

** Tables A.5 and A.6

foreach x in parl st  {
foreach y in  gen finance educ social health arts transport security economy services {

	xi: reg l_`y'_exp  CV_`x' ${controls_fe_trends}, cluster(state_code) 
	eststo l_`y'_exp_`x'_rf
		estadd ysumm, mean

	reg l_`y'_exp_pc  CV_`x' ${controls_fe_trends} , cluster(state_code) 
	eststo l_`y'_exp_pc_`x'_rf
		estadd ysumm, mean

	reg `y'_exp_perc CV_`x' ${controls_fe_trends}, cluster(state_code) 
	eststo `y'_exp_perc_`x'_rf
		estadd ysumm, mean
	
	}
	}

	
*Wild bootstrap p-values
foreach x in parl st {
foreach y in  gen finance educ social health arts transport security economy services {
cgmwildboot l_`y'_exp  CV_`x'  _Iyear_*   _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 
cgmwildboot l_`y'_exp_pc  CV_`x'  _Iyear_*  _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 
cgmwildboot `y'_exp_perc CV_`x'  _Iyear_*   _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 

}
}	


** Table A.5
*Panel A
esttab l_gen_exp_parl_rf l_finance_exp_parl_rf l_educ_exp_parl_rf l_social_exp_parl_rf l_health_exp_parl_rf l_arts_exp_parl_rf l_transport_exp_parl_rf l_security_exp_parl_rf l_economy_exp_parl_rf l_services_exp_parl_rf using "TableA5_PanelA.tex", replace mgroups("\underline {Administrative}" "\underline {Welfare}" "\underline {Infrastructure}", pattern(1 0 1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "General Admin" "Finance" "Education" "Social" "Health" "Arts" "Transport" "Security" "Economy" "Services") keep(CV_parl) b(3) se(3)  star nonotes  nonumbers staraux l starlevels(* 0.10 ** 0.05 *** .01) refcat(CV_exp_parl_rf "\bfseries{Panel A: Parliamentary Elections}") noobs scalars( "N Observations" "r2 R Squared" "ymean Mean Dep. Variable" ) sfmt ( %12.0fc %12.3fc %12.3fc  )  
*Panel B
esttab l_gen_exp_pc_parl_rf l_finance_exp_pc_parl_rf l_educ_exp_pc_parl_rf l_social_exp_pc_parl_rf l_health_exp_pc_parl_rf l_arts_exp_pc_parl_rf l_transport_exp_pc_parl_rf l_security_exp_pc_parl_rf l_economy_exp_pc_parl_rf l_services_exp_pc_parl_rf using "TableA5_PanelB.tex", replace mgroups("\underline {Administrative}" "\underline {Welfare}" "\underline {Infrastructure}", pattern(1 0 1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "General Admin" "Finance" "Education" "Social" "Health" "Arts" "Transport" "Security" "Economy" "Services") keep(CV_parl) b(3) se(3)  star nonotes  nonumbers staraux l starlevels(* 0.10 ** 0.05 *** .01) refcat(CV_exp_parl_rf "\bfseries{Panel A: Parliamentary Elections}") noobs scalars( "N Observations" "r2 R Squared" "ymean Mean Dep. Variable" ) sfmt ( %12.0fc %12.3fc %12.3fc )  
*Panel C
esttab gen_exp_perc_parl_rf finance_exp_perc_parl_rf educ_exp_perc_parl_rf social_exp_perc_parl_rf health_exp_perc_parl_rf arts_exp_perc_parl_rf transport_exp_perc_parl_rf security_exp_perc_parl_rf economy_exp_perc_parl_rf services_exp_perc_parl_rf using "TableA5_PanelC.tex", replace mgroups("\underline {Administrative}" "\underline {Welfare}" "\underline {Infrastructure}", pattern(1 0 1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "General Admin" "Finance" "Education" "Social" "Health" "Arts" "Transport" "Security" "Economy" "Services") keep(CV_parl) b(3) se(3)  star nonotes  nonumbers staraux l starlevels(* 0.10 ** 0.05 *** .01) refcat(CV_exp_parl_rf "\bfseries{Panel A: Parliamentary Elections}") noobs scalars( "N Observations" "r2 R Squared" "ymean Mean Dep. Variable" ) sfmt ( %12.0fc %12.3fc %12.3fc )  

** Table A.6
*Panel A
esttab l_gen_exp_st_rf l_finance_exp_st_rf l_educ_exp_st_rf l_social_exp_st_rf l_health_exp_st_rf l_arts_exp_st_rf l_transport_exp_st_rf l_security_exp_st_rf l_economy_exp_st_rf l_services_exp_st_rf using "TableA6_PanelA.tex", replace mgroups("\underline {Administrative}" "\underline {Welfare}" "\underline {Infrastructure}", pattern(1 0 1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "General Admin" "Finance" "Education" "Social" "Health" "Arts" "Transport" "Security" "Economy" "Services") keep(CV_st) b(3) se(3)  star nonotes  nonumbers staraux l starlevels(* 0.10 ** 0.05 *** .01) refcat(CV_exp_st_rf "\bfseries{Panel A: Stiamentary Elections}") noobs scalars( "N Observations" "r2 R Squared" "ymean Mean Dep. Variable") sfmt ( %12.0fc %12.3fc %12.3fc  )  
*Panel B
esttab l_gen_exp_pc_st_rf l_finance_exp_pc_st_rf l_educ_exp_pc_st_rf l_social_exp_pc_st_rf l_health_exp_pc_st_rf l_arts_exp_pc_st_rf l_transport_exp_pc_st_rf l_security_exp_pc_st_rf l_economy_exp_pc_st_rf l_services_exp_pc_st_rf using "TableA6_PanelB.tex", replace mgroups("\underline {Administrative}" "\underline {Welfare}" "\underline {Infrastructure}", pattern(1 0 1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "General Admin" "Finance" "Education" "Social" "Health" "Arts" "Transport" "Security" "Economy" "Services") keep(CV_st) b(3) se(3)  star nonotes  nonumbers staraux l starlevels(* 0.10 ** 0.05 *** .01) refcat(CV_exp_st_rf "\bfseries{Panel A: Stiamentary Elections}") noobs scalars( "N Observations" "r2 R Squared" "ymean Mean Dep. Variable" ) sfmt ( %12.0fc %12.3fc %12.3fc  )  
*Panel C
esttab gen_exp_perc_st_rf finance_exp_perc_st_rf educ_exp_perc_st_rf social_exp_perc_st_rf health_exp_perc_st_rf arts_exp_perc_st_rf transport_exp_perc_st_rf security_exp_perc_st_rf economy_exp_perc_st_rf services_exp_perc_st_rf using "TableA6_PanelC.tex", replace mgroups("\underline {Administrative}" "\underline {Welfare}" "\underline {Infrastructure}", pattern(1 0 1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "General Admin" "Finance" "Education" "Social" "Health" "Arts" "Transport" "Security" "Economy" "Services") keep(CV_st) b(3) se(3)  star nonotes  nonumbers staraux l starlevels(* 0.10 ** 0.05 *** .01) refcat(CV_exp_st_rf "\bfseries{Panel A: Stiamentary Elections}") noobs scalars( "N Observations" "r2 R Squared" "ymean Mean Dep. Variable" ) sfmt ( %12.0fc %12.3fc %12.3fc )  




** Tables A.7: IV 

foreach x in parl st {

		ivregress 2sls l_total_exp (turnout_`x'=CV_`x') ${controls_fe_trends}, cluster(state_code)
		eststo l_total_exp_`x'_iv
		estadd ysumm, mean
		estat firststage

		ivregress 2sls l_total_exp_pc (turnout_`x'=CV_`x') ${controls_fe_trends}, cluster(state_code)
		eststo l_total_exp_pc_`x'_iv
		estadd ysumm, mean
		estat firststage


			
	foreach y in  admin  welfare infras {

	ivregress 2sls l_`y'_exp (turnout_`x'=CV_`x') ${controls_fe_trends}, cluster(state_code) 
		eststo l_`y'_exp_`x'_iv
		estadd ysumm, mean
		estat firststage


	ivregress 2sls l_`y'_exp_pc (turnout_`x'=CV_`x') ${controls_fe_trends}, cluster(state_code) 
		eststo l_`y'_exp_pc_`x'_iv
		estadd ysumm, mean
		estat firststage

		
	ivregress 2sls `y'_exp_perc (turnout_`x'=CV_`x') ${controls_fe_trends}, cluster(state_code) 
	eststo `y'_exp_perc_`x'_iv
		estadd ysumm, mean
		estat firststage

	}
	}

	
*Wild bootstrap p-values
foreach x in parl st {
regress turnout_`x' CV_`x' l_pop unemployed_perc i.year i.state_code trend_1-trend_9, cluster(state_code) 
predict pred_turnout_`x'

cgmwildboot l_total_exp pred_turnout_`x'  _Iyear_*   _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 
cgmwildboot l_total_exp_pc pred_turnout_`x'  _Iyear_*   _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 

foreach y in  admin welfare infras {

cgmwildboot l_`y'_exp  pred_turnout_`x'  _Iyear_*   _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 
cgmwildboot l_`y'_exp_pc  pred_turnout_`x'  _Iyear_*  _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 
cgmwildboot `y'_exp_perc pred_turnout_`x'  _Iyear_*   _Istate_cod_* l_pop unemployed_perc  trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0  .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 

}
}	


*Panel A
esttab 	 l_total_exp_parl_iv l_admin_exp_parl_iv l_welfare_exp_parl_iv l_infras_exp_parl_iv l_total_exp_pc_parl_iv l_admin_exp_pc_parl_iv l_welfare_exp_pc_parl_iv l_infras_exp_pc_parl_iv admin_exp_perc_parl_iv welfare_exp_perc_parl_iv infras_exp_perc_parl_iv  using "TableA7_PanelA.tex", replace mgroups("\underline {Log-Levels}" "\underline {Log-Per Capita}" "\underline {\% of Total}", pattern(1 0 0 0 1 0 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "Total"  "Admin."  "Welfare"  "Infrast."  "Total" "Admin."  "Welfare" "Infrast."  "Admin." "Welfare" "Infrast.") keep(turnout_parl) b(3) se(3)  star nonotes  nonumbers staraux l starlevels(* 0.10 ** 0.05 *** .01) refcat(turnout_parl "\bfseries{Panel A: Parliamentary Elections}") noobs scalars( "N Observations" "r2 R Squared" "ymean Mean Dep. Variable") sfmt ( %12.0fc %12.3fc %12.3fc )  
*Panel B
esttab 	 l_total_exp_st_iv l_admin_exp_st_iv l_welfare_exp_st_iv l_infras_exp_st_iv l_total_exp_pc_st_iv l_admin_exp_pc_st_iv l_welfare_exp_pc_st_iv l_infras_exp_pc_st_iv admin_exp_perc_st_iv welfare_exp_perc_st_iv infras_exp_perc_st_iv  using "TableA7_PanelB.tex", replace mgroups("\underline {Log-Levels}" "\underline {Log-Per Capita}" "\underline {\% of Total}", pattern(1 0 0 0 1 0 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "Total"  "Admin."  "Welfare"  "Infrast."  "Total" "Admin."  "Welfare" "Infrast."  "Admin." "Welfare" "Infrast.") keep(turnout_st) b(3) se(3)  star nonotes  nonumbers l starlevels(* 0.10 ** 0.05 *** .01) refcat(turnout_st "\bfseries{Panel B: State Elections}") noobs scalars("N Observations" "r2 R Squared" "ymean Mean Dep. Variable" ) sfmt ( %12.0fc %12.3fc %12.3fc %12.3fc )  




** Table A.10 

foreach x in parl st {

		xi: reg l_total_exp CV_`x'_lead CV_`x' CV_`x'_lag ${controls_fe_trends}, cluster(state_code)
		eststo l_total_exp_`x'_l
		estadd ysumm, mean
		
		xi: reg l_total_exp_pc CV_`x'_lead CV_`x' CV_`x'_lag ${controls_fe_trends}, cluster(state_code)
		eststo l_total_exp_pc_`x'_l
		estadd ysumm, mean
		

	foreach y in  admin welfare infras{

	xi: reg l_`y'_exp  CV_`x'_lead CV_`x' CV_`x'_lag ${controls_fe_trends}, cluster(state_code) 
	eststo l_`y'_exp_`x'_l
		estadd ysumm, mean

	xi: reg l_`y'_exp_pc  CV_`x'_lead CV_`x' CV_`x'_lag ${controls_fe_trends} , cluster(state_code) 
	eststo l_`y'_exp_pc_`x'_l
		estadd ysumm, mean

	xi: reg `y'_exp_perc  CV_`x'_lead CV_`x' CV_`x'_lag ${controls_fe_trends}, cluster(state_code) 
	eststo `y'_exp_perc_`x'_l
		estadd ysumm, mean

		
	}
	}



*Wild bootstrap p-values
foreach x in parl st {
cgmwildboot l_total_exp CV_`x'_lead CV_`x' CV_`x'_lag  _Iyear_*  _Istate_cod_* l_pop unemployed_perc trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0 0 0 .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247)
cgmwildboot l_total_exp_pc CV_`x'_lead CV_`x' CV_`x'_lag  _Iyear_*  _Istate_cod_* l_pop unemployed_perc trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0 0 0 .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247)

foreach y in  admin welfare infras{
cgmwildboot l_`y'_exp CV_`x'_lead CV_`x' CV_`x'_lag  _Iyear_*  _Istate_cod_* l_pop unemployed_perc trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0 0 0 .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247)
cgmwildboot l_`y'_exp_pc CV_`x'_lead CV_`x' CV_`x'_lag _Iyear_*  _Istate_cod_* l_pop unemployed_perc trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0 0 0 .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247)
cgmwildboot `y'_exp_perc CV_`x'_lead CV_`x' CV_`x'_lag  _Iyear_*  _Istate_cod_* l_pop unemployed_perc trend_1-trend_9, cluster(state_code) bootcluster(state_code) null(0 0 0 .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247)

}
}

*Panel A
esttab 	 l_total_exp_parl_l l_admin_exp_parl_l l_welfare_exp_parl_l l_infras_exp_parl_l l_total_exp_pc_parl_l l_admin_exp_pc_parl_l l_welfare_exp_pc_parl_l l_infras_exp_pc_parl_l admin_exp_perc_parl_l welfare_exp_perc_parl_l infras_exp_perc_parl_l using "TableA10_PanelA.tex", replace mgroups("\underline {Log-Levels}" "\underline {Log-Per Capita}" "\underline {\% of Total}", pattern(1 0 0 0 1 0 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "Total"  "Admin."  "Welfare"  "Infrast."  "Total" "Admin."  "Welfare" "Infrast."  "Admin." "Welfare" "Infrast.") keep(CV_parl_lead CV_parl CV_parl_lag) b(3) se(3)  star nonotes  nonumbers  l starlevels(* 0.10 ** 0.05 *** .01) refcat(CV_parl_lead "\bfseries{Panel A: Parliamentary Elections}") noobs scalars( "N Observations" "r2 R Squared" "ymean Mean Dep. Variable" ) sfmt ( %12.0fc %12.3fc %12.3fc)  
*Panel B
esttab 	 l_total_exp_st_l l_admin_exp_st_l l_welfare_exp_st_l l_infras_exp_st_l l_total_exp_pc_st_l l_admin_exp_pc_st_l l_welfare_exp_pc_st_l l_infras_exp_pc_st_l admin_exp_perc_st_l welfare_exp_perc_st_l infras_exp_perc_st_l  using "TableA10_PanelB.tex", replace mgroups("\underline {Log-Levels}" "\underline {Log-Per Capita}" "\underline {\% of Total}", pattern(1 0 0 0 1 0 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles( "Total"  "Admin."  "Welfare"  "Infrast."  "Total" "Admin."  "Welfare" "Infrast."  "Admin." "Welfare" "Infrast.") keep(CV_st_lead CV_st CV_st_lag) b(3) se(3)  star nonotes  nonumbers l starlevels(* 0.10 ** 0.05 *** .01) refcat(CV_st_lead "\bfseries{Panel B: State Elections}") noobs scalars("N Observations" "r2 R Squared" "ymean Mean Dep. Variable" ) sfmt ( %12.0fc %12.3fc %12.3fc )  




**************************
* FIGURE 4 AND TABLE A.8 *
**************************


** Figure 4

*Turnout and Invalid Votes
clear
use		"$base\Elections.dta"

keep if year>1985
keep if parl==1

gen had_CV_parl=0
replace had_CV_parl=1 if state_code==2 | state_code==6 | state_code==7 | state_code==8


foreach y in turnout invalid{
bysort had_CV_parl year: egen mean_`y'=mean(`y')
gen mean_`y'_0=.
gen mean_`y'_1=.
replace mean_`y'_0=mean_`y' if had_CV_parl==0
replace mean_`y'_1=mean_`y' if had_CV_parl==1

}

twoway (scatter  mean_turnout_0 mean_turnout_1 year, mcolor (black gs10) legend(order (3 "Never had CV" 4 "Had CV before 1992"))) (line  mean_turnout_0 mean_turnout_1 year,  xline(1994, lcolor(black)) lpattern (solid dash) lcolor (black gs10)  xlabel(1986(3)2010) xtitle("Year") ytitle("Turnout (%)")), graphregion(fcolor(white)) 
graph save Graph "turnout_parl.gph", replace

twoway (scatter   mean_invalid_0 mean_invalid_1 year, mcolor (black gs10) legend(order (3 "Never had CV" 4 "Had CV before 1992"))) (line   mean_invalid_0 mean_invalid_1 year,  xline(1994, lcolor(black)) lpattern (solid dash) lcolor (black gs10)  ylabel(0.01(0.01)0.04) xlabel(1986(3)2010) xtitle("Year") ytitle("Invalid Votes (%)")), graphregion(fcolor(white)) 
graph save Graph "invalid_parl.gph", replace


*Expenditure

clear
use		"$base\Expenditures"
keep if year>1985 

keep year state_code  total_exp admin_exp welfare_exp infras_exp

gen had_CV_parl=0
replace had_CV_parl=1 if state_code==2 | state_code==6 | state_code==7 | state_code==8

foreach x in total admin welfare infras{
bysort had_CV_parl year: egen mean_`x'=mean(`x'_exp)
}

keep  year had_CV_parl   mean_total mean_admin mean_welfare mean_infras
duplicates drop

foreach x in total admin welfare infras{
gen l_`x'=ln(mean_`x')
}

keep  year had_CV_parl l_total l_admin l_welfare l_infras
reshape wide l_total l_admin l_welfare l_infras, i(year) j(had_CV_parl)

twoway line  l_total0 l_total1 year,  xline(1994, lcolor(black)) lpattern (solid dash) lcolor (black gs10) legend(order (1 "Never had CV" 2 "Had CV before 1992"))  xlabel(1986(3)2011) xtitle("Year") ytitle("Total Exp. (logs)") graphregion(fcolor(white)) 
graph save Graph "l_total_exp_real.gph", replace

twoway line  l_admin0 l_admin1 year,  xline(1994, lcolor(black)) lpattern (solid dash) lcolor (black gs10) legend(order (1 "Never had CV" 2 "Had CV before 1992"))  xlabel(1986(3)2011) xtitle("Year") ytitle("Administrative Exp. (logs)") graphregion(fcolor(white)) 
graph save Graph "l_admin_exp_real.gph", replace

twoway line  l_welfare0 l_welfare1 year,  xline(1994, lcolor(black)) lpattern (solid dash) lcolor (black gs10) legend(order (1 "Never had CV" 2 "Had CV before 1992"))  ylabel(7(0.5)8) xlabel(1986(3)2011) xtitle("Year") ytitle("Welfare Exp. (logs)") graphregion(fcolor(white)) 
graph save Graph "l_welfare_exp_real.gph", replace

twoway line  l_infras0 l_infras1 year,  xline(1994, lcolor(black)) lpattern (solid dash) lcolor (black gs10) legend(order (1 "Never had CV" 2 "Had CV before 1992"))  xlabel(1986(3)2011) xtitle("Year") ytitle("Infrastructure Exp. (logs)") graphregion(fcolor(white)) 
graph save Graph "l_infras_exp_real.gph", replace

grc1leg  "turnout_parl.gph"  "invalid_parl.gph"  "l_total_exp_real.gph"  "l_admin_exp_real.gph" "l_welfare_exp_real.gph" "l_infras_exp_real.gph", cols(2) graphregion(fcolor(white)) xcommon
graph save Graph "Figure4.gph"


** Table A.8
clear
use		"$base\Elections.dta"

keep if year>1985

*Turnout and Invalid Votes
foreach y in turnout invalid  {
xi: reg `y' CV_parl  i.year i.state_code  l_pop  unemployed_perc  if parl==1, cluster(state_code)
	eststo `y'
	estadd ysumm, mean
}

*State and year FE for wild bootstrap regressions
foreach x in 1986 1990 1994 1995 1999 2002 2008 {
gen y_`x'=(year==`x')
}

foreach x in 2 3 4 5 6 7 8 9{
gen state_`x'=(state_code==`x')
}

*Wild bootstrap p-values
foreach y in turnout invalid  {
cgmwildboot `y' CV  _Iyear_*  _Istate_cod_* l_pop  unemployed_perc  if parl==1, cluster(state_code) bootcluster(state_code) null(0 . . .   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247)  
}


clear
use "$base\Expenditures.dta", replace
keep if year>1985


*Expenditures
foreach y in  total admin welfare infras {
xi: reg l_`y'_exp  CV_parl i.year i.state_code l_pop  unemployed_perc, cluster(state_code) 
	eststo l_`y'_exp
	estadd ysumm, mean

	}
	
	

foreach y in  total admin welfare infras {
cgmwildboot l_`y'_exp CV_parl   _Iyear_*  _Istate_cod_*  l_pop  unemployed_perc , cluster(state_code) bootcluster(state_code) null(0 . . . . . . . . . . .  . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247)  
}



esttab turnout invalid l_total_exp l_admin_exp l_welfare_exp l_infras_exp using "$results\TableA8.tex", replace  mtitles("Turnout (\%)" "Invalid Votes (\%)" "Total Exp. (in logs)" "Admin. Exp. (in logs)"  "Welfare Exp. (in logs)" "Infrast. Exp. (in logs)") keep(CV_parl) b(3) se(3) star nonotes   l nonumbers width(\hsize) starlevels(* 0.10 ** 0.05 *** .01) noobs scalars("N Observations" "r2 R Squared" "ymean Mean Dep. Variable") sfmt (%12.0fc %12.3fc %12.3fc)



********************
** TABLES 2 AND 6 **
********************

clear
use "$base\ASS.dta"


* Table 2
estpost sum  voted party_pref_left party_pref_right party_pref_other party_pref_none  not_party_member polit_inter_1 polit_inter_2 polit_inter_3  doesnt_read_newspaper    age female mid_HH_income_euros HH_size works  unempl pensioneer   compulsory_schooling vocational_mschool academic_hschool college if voted!=.
est store stats
esttab stats using "Table2.tex", replace refcat(voted "\bfseries{Turnout/Exposure to CV}" party_pref_left "\bfseries{Political Party of Preference and Affiliation}" polit_inter_1 "\bfseries{Interest in Politics and Information}" age "\bfseries{{Socioeconomic Variables}" compulsory_schooling "\bfseries{Educational Attainment}") cells("count(fmt(%9.0g)) mean(fmt(2)) sd(fmt(2)) min(fmt(2)) max(fmt(2))") noobs collabels("Observations" "Mean" "Std. Dev" "Min" "Max")  label nonum



* Table 6
keep if sample_with_controls==1 
global controls age age_2 female compulsory_schooling vocational_mschool compulsory_schooling_f vocational_mschool_f  compulsory_schooling_m vocational_mschool_m   HH_size  comm_size_1 comm_size_2  works pensioneer  party_pref_left party_pref_right party_pref_none   reads_newspaper party_member  polit_inter_1 polit_inter_2   wave2 state_code_2-state_code_9


*1) Effect of CV on turnout
reg voted CV  ${controls}, cluster(state_code)
		qui eststo reg1
		
*2) By gender		
reg voted female_CV male_CV ${controls},  cluster(state_code)
		qui eststo reg2

		
*3) By educational attainment 
reg voted  compulsory_schooling_CV vocational_mschool_CV hschool_more_CV ${controls},  cluster(state_code) 
		qui eststo reg3
		
		
*4) By income quartile
reg voted income_Q1_CV income_Q2_CV income_Q3_CV income_Q4_CV  income_Q1  income_Q2 income_Q3  ${controls},  cluster(state_code) 
		qui eststo reg4
	
		
*5) By political party membership	
reg voted   party_member_CV not_party_member_CV   ${controls},  cluster(state_code)
		qui eststo reg5
		
*6) By degree of information
reg voted  reads_newspaper_CV doesnt_read_newspaper_CV   ${controls}, cluster(state_code)
		qui eststo reg6
		
		
*7) By interest in politics	
reg voted polit_inter_1_CV polit_inter_2_CV polit_inter_3_CV   ${controls},  cluster(state_code) 
		qui eststo reg7

		
		
*8) By self reported political preferences 
reg voted  party_pref_left_CV party_pref_right_CV party_pref_none_CV party_pref_other_CV ${controls}, cluster(state_code) 
		qui eststo reg8
	

*Wild bootstrap p-values
cgmwildboot voted CV ${controls}, cluster(state_code) bootcluster(state_code) null(0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 

cgmwildboot voted female_CV male_CV  ${controls} , cluster(state_code) bootcluster(state_code) null(0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .)  reps(999) seed(365476247) 

cgmwildboot voted compulsory_schooling_CV vocational_mschool_CV hschool_more_CV  ${controls} , cluster(state_code) bootcluster(state_code) null(0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247) 

cgmwildboot voted income_Q1_CV income_Q2_CV income_Q3_CV income_Q4_CV  income_Q1  income_Q2 income_Q3 income_Q4   ${controls} , cluster(state_code) bootcluster(state_code) null(0  0 0 0 . . . .   . . . . . . . . . .  . . . . . . . . . .  . . . . . . . . . .)  reps(999) seed(365476247) 

cgmwildboot voted party_member_CV not_party_member_CV   ${controls} , cluster(state_code) bootcluster(state_code) null(0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247) 

cgmwildboot voted reads_newspaper_CV doesnt_read_newspaper_CV   ${controls} , cluster(state_code) bootcluster(state_code) null(0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247) 

cgmwildboot voted polit_inter_1_CV polit_inter_2_CV polit_inter_3_CV   ${controls} , cluster(state_code) bootcluster(state_code) null(0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247) 

cgmwildboot voted party_pref_left_CV party_pref_right_CV party_pref_none_CV party_pref_other_CV   ${controls} , cluster(state_code) bootcluster(state_code) null(0  0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )  reps(999) seed(365476247) 

	
esttab  reg1 reg2 reg3 reg4  using "Table6_col1.tex", replace  mtitles ("" "" "") mgroups("Dependent Variable: Voted in Last Parliamentary Elections", pattern(1 0 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) refcat(CV "\bfseries{1) Effect of CV on Turnout}" female_CV "\bfseries{2) Gender}" compulsory_schooling_CV "\bfseries{3) Educational Attainment}" Income_Q1_CV "\bfseries{4) Income Quartile}", nolabel) keep(CV female_CV male_CV compulsory_schooling_CV vocational_mschool_CV hschool_more_CV income_Q1_CV income_Q2_CV income_Q3_CV income_Q4_CV ) b(3) se(3) width(1\hsize) star nonotes  nonumbers  l starlevels(* 0.10 ** 0.05 *** .01)  noobs scalars("N Observations" "r2 R Squared") sfmt (%12.0fc %12.3fc) 
esttab  reg5 reg6 reg7 reg8  using "Table6_col2.tex", replace mtitles ("" "" "") keep( not_party_member_CV  party_member_CV doesnt_read_newspaper_CV reads_newspaper_CV  polit_inter_1_CV polit_inter_2_CV polit_inter_3_CV  party_pref_left_CV party_pref_right_CV  party_pref_other_CV party_pref_none_CV) refcat(party_member_CV  "\bfseries{5) Party Membership}" reads_newspaper_CV  "\bfseries{6) Informed. vs Uninformed Citizens}" polit_inter_1_CV "\bfseries{7) Interest in Politics}" party_pref_left_CV "\bfseries{8) Self-Reported Political Preference}"  , nolabel ) mgroups("Dependent Variable: Voted in Last Parliamentary Elections", pattern(1 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) b(3) se(3) width(1\hsize) star nonotes  nonumbers l starlevels(* 0.10 ** 0.05 *** .01)  noobs scalars("N Observations" "r2 R Squared") sfmt ( %12.0fc %12.3fc) 













	

